package com.zhidisoft.system.action;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zhidisoft.base.action.BaseAction;
import com.zhidisoft.common.ResultData;
import com.zhidisoft.system.entity.Function;
import com.zhidisoft.system.entity.Role;
import com.zhidisoft.system.entity.User;
import com.zhidisoft.system.vo.MenuVO;

@SuppressWarnings("all")
@Controller
@Scope("prototype")
public class IndexAction extends BaseAction {
	
	public String execute(){
		return "index";
	}
	
	public String menu() throws Exception{
		//获取当前登录用户信息
		User user = getCurrentUser();
		
		List<MenuVO> menus = menuService.findMenu(user);
		//判断权限菜单中有无菜单项目，如无提示用户无权限
		if(menus == null || menus.isEmpty()){
			resultData = ResultData.buildFailureResult("当前用户暂未获取系统操作权限，请与管理员联系!");
			printJSONObject(resultData);
			return NONE;
		}
		//装配权限菜单数据，返回给客户端
		resultData = ResultData.buildSuccessResult("加载权限菜单成功", menus);
		printJSONObject(resultData);
		return NONE;
	}

}
